home *** CD-ROM | disk | FTP | other *** search
- head 1.5;
- branch ;
- access ;
- symbols sprited:1.4.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.5
- date 92.03.27.13.42.48; author rab; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 90.09.11.14.28.34; author kupfer; state Exp;
- branches 1.4.1.1;
- next 1.3;
-
- 1.3
- date 88.07.25.11.16.44; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.06.27.17.23.39; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.06.19.14.33.04; author ouster; state Exp;
- branches ;
- next ;
-
- 1.4.1.1
- date 91.10.22.14.53.20; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.5
- log
- @Fixed a couple lint errors.
- @
- text
- @/*
- * Time_ToAscii.c --
- *
- * Source code for the Time_ToAscii library procedure.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/time/RCS/Time_ToAscii.c,v 1.4 90/09/11 14:28:34 kupfer Exp Locker: rab $ SPRITE (Berkeley)";
- #endif not lint
-
- #include <sprite.h>
- #include <spriteTime.h>
- #include <string.h>
-
- /*
- * Forward declarations:
- */
-
- static void ConvertToNum _ARGS_((char *cp, int n, Boolean blank));
-
-
- /*
- *----------------------------------------------------------------------
- *
- * ConvertToNum --
- *
- * Converts a number into ascii string. The blank argument,
- * if TRUE specifies blank padding, and if FALSE, specifies
- * zero padding.
- *
- * Result:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- static void
- ConvertToNum(cp, n, blank)
- register char *cp;
- int n;
- Boolean blank;
- {
- if (n>=10) {
- *cp = (n/10)%10 + '0';
- } else if (blank) {
- *cp = ' ';
- }
- cp++;
- *cp = n%10 + '0';
- }
-
- /*
- *----------------------------------------------------------------------
- *
- * Time_ToAscii --
- *
- * Converts a time value into a human-readable string of
- * the current (absolute) time or relative time.
- * The current time has the form:
- * Wed, 1 Jan 86 10:24:38
- * If relative time is specified, the time value is interpreted
- * as the difference between two absolute time values and has the form:
- * 0 days, 02:45:09
- *
- * Note: this routine can be simplied once a sprintf routine is available.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- void
- Time_ToAscii(time, relativeTime, bufferPtr)
- int time;
- Boolean relativeTime;
- char *bufferPtr;
- {
- register char *cp, *ncp;
- Time_Parts parts;
-
- Time_ToParts(time, relativeTime, &parts);
-
-
- if (relativeTime) {
- (void) strcpy(bufferPtr, " 00+00:00:00");
- /* 012345678901+1 for null byte*/
-
- #define DAY_OFFSET 1
- #define HOUR_OFFSET 4
- #define MINUTE_OFFSET 7
- #define SECOND_OFFSET 10
-
- cp = &bufferPtr[SECOND_OFFSET];
- ConvertToNum(cp, parts.seconds, FALSE);
-
- cp = &bufferPtr[MINUTE_OFFSET];
- ConvertToNum(cp, parts.minutes, FALSE);
-
- cp = &bufferPtr[HOUR_OFFSET];
- ConvertToNum(cp, parts.hours, FALSE);
-
- cp = &bufferPtr[DAY_OFFSET];
- if (parts.dayOfYear < 0) {
- bufferPtr[0] = '-';
- ConvertToNum(cp, -parts.dayOfYear, TRUE);
- } else {
- ConvertToNum(cp, parts.dayOfYear, TRUE);
- }
-
-
- } else {
-
- /*
- * Use the Arpanet standard format for date & time.
- * The timezone is ignored for now (goes at the end of the line).
- */
-
- (void) strcpy(bufferPtr, "Day, DD MMM YY 00:00:00");
- /* 01234567890123456789012 +1 for null byte*/
-
- #define DAY_OF_WEEK 0
- #define DAY_OF_MONTH 5
- #define MONTH 8
- #define YEAR 12
- #define HOUR 15
- #define MINUTE 18
- #define SECOND 21
- #define TIMEZONE 24
-
- cp = &bufferPtr[SECOND];
- ConvertToNum(cp, parts.seconds, FALSE);
-
- cp = &bufferPtr[MINUTE];
- ConvertToNum(cp, parts.minutes, FALSE);
-
- cp = &bufferPtr[HOUR];
- ConvertToNum(cp, parts.hours, FALSE);
-
- ncp = &"SunMonTueWedThuFriSat"[3* parts.dayOfWeek ];
- cp = &bufferPtr[DAY_OF_WEEK];
- cp[0] = ncp[0];
- cp[1] = ncp[1];
- cp[2] = ncp[2];
- cp += 3;
- ncp += 3;
-
- cp = &bufferPtr[YEAR];
- ConvertToNum(cp, parts.year, FALSE); /* last 2 digits of year */
-
- cp = &bufferPtr[MONTH];
- ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[parts.month*3];
- cp[0] = ncp[0];
- cp[1] = ncp[1];
- cp[2] = ncp[2];
- cp += 3;
- ncp += 3;
-
- cp = &bufferPtr[DAY_OF_MONTH];
- ConvertToNum(cp, parts.dayOfMonth, TRUE);
- }
-
- }
- @
-
-
- 1.4
- log
- @Use function prototypes.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/time/RCS/Time_ToAscii.c,v 1.3 88/07/25 11:16:44 ouster Exp Locker: kupfer $ SPRITE (Berkeley)";
- d101 1
- a101 1
- strcpy(bufferPtr, " 00+00:00:00");
- d134 1
- a134 1
- strcpy(bufferPtr, "Day, DD MMM YY 00:00:00");
- @
-
-
- 1.4.1.1
- log
- @Initial branch for Sprite server.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/time/RCS/Time_ToAscii.c,v 1.4 90/09/11 14:28:34 kupfer Exp Locker: rab $ SPRITE (Berkeley)";
- @
-
-
- 1.3
- log
- @Lint.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: Time_ToAscii.c,v 1.2 88/06/27 17:23:39 ouster Exp $ SPRITE (Berkeley)";
- d23 6
- @
-
-
- 1.2
- log
- @Use spriteTime.h instead of time.h.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: Time_ToAscii.c,v 1.1 88/06/19 14:33:04 ouster Exp $ SPRITE (Berkeley)";
- d22 1
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
- d21 1
- a21 1
- #include "time.h"
- @
-